// fxobj.txt 

// Like a basic talking object, but it also creates sparkels on itself
// Cell 0 - The talk code to begin the conversation at.
// Cell 1 - The number of the sfx to make
// Cell 2 - number of sfxes to make, defaults to 6
// Cell 3 - floater value
	// floater values:
	// 0 - stationary
	// 1 - floats slowly into air
	// 2 - starts high in air, drifts down
	// 3 - starts high in air, drifts down, drawn as addover
// Cell 4,5 - The sdf to see if sparkels and cbe or not

beginobjectscript; // talking object

variables;

short num_fx = 6;
short sparkles = 1;
short cur_tick;
short wanna_boom = 0;

body;

beginstate INIT_STATE;
	cur_tick = get_current_tick();
	if (get_memory_cell(2) != 0)
		num_fx = get_memory_cell(2);
break;

beginstate DEAD_STATE;
	break;
	
beginstate START_STATE; 
	if (wanna_boom > 1)
		end();
		
	if (gf(10,27 + get_memory_cell(0)) == 1) {
		inc_flag(10,27 + get_memory_cell(0),1);
		cur_tick = get_current_tick();
		}
		else if ((gf(10,27 + get_memory_cell(0)) > 1) && (cur_tick != get_current_tick())) {
			if (wanna_boom == 1) {
				create_text_bubble("Kaboom!");
				print_str_color("The pylon explodes!",3);
	  			create_missile_spiral(155,40,6,2);
				damage_nearby(400 + get_ran(1,0,100),5,1,0);
				damage_nearby(400 + get_ran(1,0,100),5,1,1);
				play_sound(165); 
				wanna_boom = 2;
				sf(12,16,1);
				end();
				}
				
			cur_tick = get_current_tick();
			if (char_ok(8) == FALSE) {
				print_str_color("The pylon loses power.",3);
				sf(10,27 + get_memory_cell(0),0); 
				end();
				}
				
			inc_flag(10,27 + get_memory_cell(0),1);
			if (gf(10,27 + get_memory_cell(0)) == 2) {
				create_text_bubble("Zzzt!");
				run_sparkles_on_object(ME,15,4,1);
				print_str_color("The pylon continues to charge up.",3);
				}
			if (gf(10,27 + get_memory_cell(0)) == 3) {
				create_text_bubble("Zzzt!");
				run_sparkles_on_object(ME,15,4,1);
				print_str_color("The pylon continues to charge up.",3);
				}
			if (gf(10,27 + get_memory_cell(0)) == 4) {
				run_sparkles_on_object(ME,15,8,1);
				create_text_bubble("Zzzt! Zzzzzt!");
				print_str_color("The pylon is almost charged up.",3);
				}
			if (gf(10,27 + get_memory_cell(0)) == 5) {
				if (gf(12,23) == 2) {
					wanna_boom = 1;
					begin_talk_mode(5);
					end();
					}
				create_text_bubble("Kaboom!");
				run_sparkles_on_object(ME,16,12,1);
				print_str_color("The pylon discharges its energy.",3);
				sf(10,27 + get_memory_cell(0),0); 
				
				play_sound(165); 
				run_sparkles_on_object(ME,162,1,4);
	  			create_missile_spiral(155,40,6,2);
				
				if (get_attitude(8) < 10) {
					damage_nearby(250 + get_ran(1,0,50),6,2,1);
					status_nearby(20,6,20,1);
					}
					else if (gf(12,23) < 2) {
						status_nearby(5,6,20,0);
						if (gf(12,23) == 1) {
							print_str_color("  Your sabotage reduces its power.",3);
							damage_nearby(100 + get_ran(1,0,100),6,1,0);
							}
							else {
								status_nearby(-12,6,1,0);
								damage_nearby(300 + get_ran(1,0,100),6,1,0);
								}
						}

				}
			
			
			
			}

		
	break;
	
beginstate USE_STATE;
	if (wanna_boom > 1)
		print_str_color("The machinery is a pile of wreckage.",2);
		else begin_talk_mode(260 + 5 * get_memory_cell(0));
break;
